Skip to content

Conversation

@rgommers
Copy link
Contributor

@rgommers rgommers commented May 17, 2024

This is a follow-up to gh-495.

There are several ways that meson may go missing:

The git submodule case was ending with:

meson-python: error: Could not find meson version 0.63.3 or newer, found .

and after this ends with:

meson-python: error: Could not find specified meson: vendored-meson/meson/meson.py

If the executable is missing, the build ended with a very long traceback. Changing FileNotFoundError to ConfigError elides the traceback and clearly reports that the executable wasn't found. Easy to verify with any package with:

$ MESON=nonsense python -m build -wnx
* Building wheel...

meson-python: error: meson executable `nonsense` not found

ERROR Backend subproccess exited when trying to invoke build_wheel

Closes numpy/numpy#26397

@rgommers rgommers added the maintenance Regular code improvements that are not new features nor end-user-visible bugs label May 17, 2024
@rgommers rgommers force-pushed the improve-custom-meson-error branch from b292895 to e0f4c97 Compare May 17, 2024 10:29
Copy link
Member

@dnicolodi dnicolodi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @rgommers. It looks good, except for some nitpicking about the spelling of the error messages. Curiously I have similar patch queued locally. In that I also check the return code of meson --version and raise an error with what was printed on the standard error if the return code is not zero.

There are several ways that meson may go missing:
- a non-isolated build and meson isn't installed
- meson executable is specified in pyproject.toml and git submodule
  is containing it is not initialized (reported as resulting in a
  confusing error in numpy#26397)
- MESON environmnent variable is used by the user and is misspelled

The git submodule case was ending with:
```
meson-python: error: Could not find meson version 0.63.3 or newer, found .
```
and after this ends with:
```
meson-python: error: Could not find the specified meson: "vendored-meson/meson/meson.py"
```

If the executable is missing, the build ended with a very long
traceback. Changing `FileNotFoundError` to `ConfigError` elides the
traceback and clearly reports that the executable wasn't found. Easy to
verify with any package with:
```
$ MESON=nonsense python -m build -wnx
* Building wheel...

meson-python: error: meson executable "nonsense" not found

ERROR Backend subproccess exited when trying to invoke build_wheel
```
@rgommers rgommers force-pushed the improve-custom-meson-error branch from e0f4c97 to 1dd18b6 Compare May 17, 2024 11:41
@rgommers
Copy link
Contributor Author

Thanks @dnicolodi. Adopted your suggestions for error messages.

In that I also check the return code of meson --version and raise an error with what was printed on the standard error if the return code is not zero.

If you have that already, do you want to put that on top of this PR (either push a commit or do in a follow-up PR)?

@dnicolodi
Copy link
Member

Sure, I will do that later today.

@dnicolodi dnicolodi merged commit dc23cff into mesonbuild:main May 19, 2024
@rgommers rgommers deleted the improve-custom-meson-error branch May 19, 2024 12:01
@rgommers rgommers added this to the v0.17.0 milestone May 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Regular code improvements that are not new features nor end-user-visible bugs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BLD: A fresh clone without submodules fails to build inscrutably

2 participants